import HTTP from '../utils/http';
import { API } from '../config/config';
import { Message } from 'element-ui';
import { axiosMessageShow } from '@/utils/tools';
const FIRENDLINK = API.FIREND;

export default class FirendLinkClass extends HTTP {
    findFirendLink(id) {
        return new Promise((resolve) => {
            this.axiosPost({
                url: FIRENDLINK.FIREND_GET,
                data: id,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data.data)
                }, error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })
                }
            })
        })
    }
    destroyFirendLink(id) {
        return new Promise((resolve) => {
            this.axiosPost({
                url: FIRENDLINK.FIREND_DESTROY,
                data: id,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data)
                }, error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })
                }
            })
        })
    }
    createFirendLink(data) {
        return new Promise((resolve) => {
            this.axiosPost({
                url: FIRENDLINK.FIREND_CREATE,
                data,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data)
                }, error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })
                }
            })
        })
    }
    updateFirendLink(data) {
        return new Promise((resolve) => {
            this.axiosPost({
                url: FIRENDLINK.FIREND_UPDATE,
                data,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data)
                }, error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })
                }
            })
        })
    }

}

